package edu.zut.cs.software.perfect.course.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.web.bind.annotation.CrossOrigin;

import edu.zut.cs.software.perfect.base.domain.BaseTreeEntity;

/**
 * @ClassName CourseCategory
 * @Description TODO
 * @Author liangying
 * @Date 2020年5月29日 下午3:13:00
 * @Version 1.0
 */
/**
 * The curriculum category and curriculum 
 * form a one-to-many relationship
 * The classes are tree-shaped
 * @author xiaoyingzi
 *
 */
@CrossOrigin
@Entity
@Table(name = "T_COURSE_CATEGORY")
@NamedQueries({ @NamedQuery(name = "CourseCategory.getRoot", query = "select m from CourseCategory m where m.parent is null") })
public class CourseCategory extends BaseTreeEntity<CourseCategory, Long>{

	/**
	 * Serializing
	 */
	private static final long serialVersionUID = -3146637001214843163L;

	/**
	 * The code of the course category
	 */
	@Column
	String categoryCode;
	
	/**
	 * The name of the course category
	 */
	@Column
	String categoryName;
	
	/**
	 * Build a one-to-many relationship
	 * Each course category corresponds to multiple courses
	 */
	@OneToMany(mappedBy = "courseCategory", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	List<CourseInformation> courses;

	public String getCategoryCode() {
		return categoryCode;
	}

	public void setCategoryCode(String categoryCode) {
		this.categoryCode = categoryCode;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}
	
}
